from uuid import uuid4
from app import db
from DeviceManager.models import Device


class User(db.Model):
    __tablename__ = "users"
    __table_args__ = {"schema": "AeroSentinel"}
    uuid = db.Column(db.String(36), primary_key=True, default=lambda: str(uuid4()))
    username = db.Column(db.String(16), nullable=False, unique=True)
    password = db.Column(db.String(32), nullable=False)
    permission = db.Column(db.BINARY(1))  # 8位二进制数
    devices = db.relationship(Device, backref="user", lazy=True)
    wxid = db.Column(db.String(32), nullable=True, unique=True)
